import service from "@/utils/request";

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 登录api接口集合
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 */
// 用户注册
export function useLoginApi(data: object | null | undefined) {
  return service({
    url: "/oauth-service/v1/sys-user/logon",
    method: "post",
    data,
  });
}
// 短信验证
export function sendNote(data: { messageType: string| undefined; phone: string }) {
  return service({
    url:
      "/xinfa-service/v1/message/send?messageType=" +
      data.messageType +
      "&phone=" +
      data.phone,
    method: "post",
  });
}
// 账号密码登录
export function loginAccount(data: object | null | undefined) {
  return service({
    url: "/oauth-service/v1/user/login/account",
    method: "post",
    data,
  });
}
// 微信扫码登录
export function loginweChat(data: { linkSystem: string; openId: string }) {
  return service({
    url:
      "/oauth-service/v1/user/login/weChat?linkSystem=" +
      data.linkSystem +
      "&openId=" +
      data.openId,
    method: "post",
    data,
  });
}
// 手机验证码登录
export function loginPhone(data: {phone:any,code:any,linkSystem:any,loginType:any}) {
  return service({
    url: "/oauth-service/v1/user/login/phone?phone=" + data.phone + '&code=' + data.code + '&linkSystem=' + data.linkSystem+ '&loginType='+data.loginType,
    method: "post"
  });
}
// 忘记密码
export function forgotPassword(data: any) {
  return service({
    url: "/oauth-service/v1/user/forgotPassword",
    method: "post",
    data,
  });
}
// 修改密码
export function sendPassword(data: any) {
  return service({
    url: "/oauth-service/v1/sys-user/change-password",
    method: "post",
    data,
  });
}
// 退出登录
export function logout() {
  return service({
    url: "/oauth-service/v1/user/logout",
    method: "post"
  });
}
